package com.gitee.minimalismstyle.fresh.simple.api.service

import com.gitee.minimalismstyle.fresh.common.core.domain.QueryBody
import com.gitee.minimalismstyle.fresh.common.core.domain.QueryParams
import com.gitee.minimalismstyle.fresh.common.core.domain.R
import com.gitee.minimalismstyle.fresh.common.core.domain.Simple
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
import org.springframework.web.bind.annotation.*

@Api(value = "simple", tags = ["通用功能接口"])
@RestController
@RequestMapping("simple")
interface SimpleService {

    @ApiOperation("分页查询")
    @GetMapping("/{code}/find")
    fun find(@ApiParam(required = true, value = "列表代码")
             @PathVariable
             code: String, params: QueryParams<Simple>): R<QueryBody<Simple>>

    @ApiOperation("导出数据")
    @GetMapping("/{code}/export")
    fun export(@ApiParam(required = true, value = "列表代码")
               @PathVariable
               code: String, params: QueryParams<Simple>)

    @ApiOperation("分页查询")
    @GetMapping("/{code}/findByQueryParams")
    fun findByQueryParams(@ApiParam(required = true, value = "sql代码")
                          @PathVariable
                          code: String, params: QueryParams<Simple>): R<QueryBody<Simple>>

    @ApiOperation("查询单条")
    @GetMapping("/{code}/findOne")
    fun findOne(@ApiParam(required = true, value = "sql代码")
                @PathVariable
                code: String, params: QueryParams<Simple>): R<Simple>

    @ApiOperation("查询列表")
    @GetMapping("/{code}/findAll")
    fun findAll(@ApiParam(required = true, value = "sql代码")
                @PathVariable
                code: String, params: QueryParams<Simple>): R<List<Simple>>


    @ApiOperation("执行更新")
    @PostMapping("/{code}/update")
    fun update(@ApiParam(required = true, value = "sql代码")
               @PathVariable
               code: String, simple: Simple): R<Simple>

    @ApiOperation("执行添加")
    @PostMapping("/{code}/insert")
    fun insert(@ApiParam(required = true, value = "sql代码")
               @PathVariable
               code: String, simple: Simple): R<Simple>

    @ApiOperation("执行删除")
    @DeleteMapping("/{code}/delete")
    fun delete(@ApiParam(required = true, value = "sql代码")
               @PathVariable
               code: String, simple: Simple): R<Simple>
}